<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div style="width: 800px;margin: 20px auto; text-align: center;">
	<h1>学员信息列表</h1>
	<table width="800" border="1">
		<tr>
			<th>学员编号</th>
			<th>学员姓名</th>
			<th>学员性别</th>
			<th>学员年龄</th>
			<th>家庭住址</th>
			<th>Email</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${stuList }" var="stu">
			<tr>
				<td>${stu.sid }</td>
				<td><a href="get?sid=${stu.sid }">${stu.sname }</a></td>
				<td>${stu.sgender }</td>
				<td>${stu.sage }</td>
				<td>${stu.saddress }</td>
				<td>${stu.semail }</td>
				<td><a href="del?sid=${stu.sid }" class="del">删除</a></td>
			</tr>
		</c:forEach>
	</table>
</div>
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<script type="text/javascript">
$(function(){
	$(".del").click(function(){
		var that = $(this);
		if(confirm("确定删除吗?")){
			$.ajax({
				url:that.attr("href"),
				type:"get",
				data:"",
				dataType:"text",
				success:function(n){
					if(n>0){
						alert("删除成功")
						that.closest("tr").remove();
					}else{
						alert("删除失败")
					}
				},
				error:function(){
					alert("删除失败")
				}
			})
		}
		return false;
	})
})
</script>
</body>
</html>